import 'package:factoryside/bean/order_detail_entity.dart';

orderDetailEntityFromJson(OrderDetailEntity data, Map<String, dynamic> json) {
	if (json['OrderID'] != null) {
		data.orderID = json['OrderID'] is String
				? int.tryParse(json['OrderID'])
				: json['OrderID'].toInt();
	}
	if (json['OrderNumber'] != null) {
		data.orderNumber = json['OrderNumber'].toString();
	}
	if (json['State'] != null) {
		data.state = json['State'].toString();
	}
	if (json['StateHtml'] != null) {
		data.stateHtml = json['StateHtml'].toString();
	}
	if (json['CreateDate'] != null) {
		data.createDate = json['CreateDate'];
	}
	if (json['UserName'] != null) {
		data.userName = json['UserName'].toString();
	}
	if (json['Address'] != null) {
		data.address = json['Address'].toString();
	}
	if (json['FullAddress'] != null) {
		data.fullAddress = json['FullAddress'].toString();
	}
	if (json['Phone'] != null) {
		data.phone = json['Phone'].toString();
	}
	if (json['SparePhone'] != null) {
		data.sparePhone = json['SparePhone'].toString();
	}
	if (json['Guarantee'] != null) {
		data.guarantee = json['Guarantee'].toString();
	}
	if (json['TypeName'] != null) {
		data.typeName = json['TypeName'].toString();
	}
	if (json['TypeID'] != null) {
		data.typeID = json['TypeID'] is String
				? int.tryParse(json['TypeID'])
				: json['TypeID'].toInt();
	}
	if (json['UserID'] != null) {
		data.userID = json['UserID'].toString();
	}
	if (json['SendUser'] != null) {
		data.sendUser = json['SendUser'].toString();
	}
	if (json['RelationOrderID'] != null) {
		data.relationOrderID = json['RelationOrderID'] is String
				? int.tryParse(json['RelationOrderID'])
				: json['RelationOrderID'].toInt();
	}
	if (json['ProvinceCode'] != null) {
		data.provinceCode = json['ProvinceCode'].toString();
	}
	if (json['CityCode'] != null) {
		data.cityCode = json['CityCode'].toString();
	}
	if (json['AreaCode'] != null) {
		data.areaCode = json['AreaCode'].toString();
	}
	if (json['DistrictCode'] != null) {
		data.districtCode = json['DistrictCode'].toString();
	}
	if (json['IsMessage'] != null) {
		data.isMessage = json['IsMessage'];
	}
	if (json['ThirdPartyOrderNumber'] != null) {
		data.thirdPartyOrderNumber = json['ThirdPartyOrderNumber'].toString();
	}
	if (json['OrderProductModels'] != null) {
		data.orderProductModels = new List<OrderDetailOrderProductModel>();
		(json['OrderProductModels'] as List).forEach((v) {
			data.orderProductModels.add(new OrderDetailOrderProductModel().fromJson(v));
		});
	}
	if (json['MasterInfo'] != null) {
		data.masterInfo = new OrderDetailMasterInfo().fromJson(json['MasterInfo']);
	}
	return data;
}

Map<String, dynamic> orderDetailEntityToJson(OrderDetailEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['OrderID'] = entity.orderID;
	data['OrderNumber'] = entity.orderNumber;
	data['State'] = entity.state;
	data['StateHtml'] = entity.stateHtml;
	data['CreateDate'] = entity.createDate;
	data['UserName'] = entity.userName;
	data['Address'] = entity.address;
	data['FullAddress'] = entity.fullAddress;
	data['Phone'] = entity.phone;
	data['SparePhone'] = entity.sparePhone;
	data['Guarantee'] = entity.guarantee;
	data['TypeName'] = entity.typeName;
	data['TypeID'] = entity.typeID;
	data['UserID'] = entity.userID;
	data['SendUser'] = entity.sendUser;
	data['RelationOrderID'] = entity.relationOrderID;
	data['ProvinceCode'] = entity.provinceCode;
	data['CityCode'] = entity.cityCode;
	data['AreaCode'] = entity.areaCode;
	data['DistrictCode'] = entity.districtCode;
	data['IsMessage'] = entity.isMessage;
	data['ThirdPartyOrderNumber'] = entity.thirdPartyOrderNumber;
	if (entity.orderProductModels != null) {
		data['OrderProductModels'] =  entity.orderProductModels.map((v) => v.toJson()).toList();
	}
	if (entity.masterInfo != null) {
		data['MasterInfo'] = entity.masterInfo.toJson();
	}
	return data;
}

orderDetailOrderProductModelFromJson(OrderDetailOrderProductModel data, Map<String, dynamic> json) {
	if (json['CategoryName'] != null) {
		data.categoryName = json['CategoryName'].toString();
	}
	if (json['SubCategoryName'] != null) {
		data.subCategoryName = json['SubCategoryName'].toString();
	}
	if (json['ProductType'] != null) {
		data.productType = json['ProductType'].toString();
	}
	if (json['ProdModelName'] != null) {
		data.prodModelName = json['ProdModelName'].toString();
	}
	if (json['BrandName'] != null) {
		data.brandName = json['BrandName'].toString();
	}
	if (json['Memo'] != null) {
		data.memo = json['Memo'].toString();
	}
	if (json['Num'] != null) {
		data.num = json['Num'] is String
				? int.tryParse(json['Num'])
				: json['Num'].toInt();
	}
	if (json['OrderProdcutID'] != null) {
		data.orderProdcutID = json['OrderProdcutID'] is String
				? int.tryParse(json['OrderProdcutID'])
				: json['OrderProdcutID'].toInt();
	}
	if (json['SubCategoryID'] != null) {
		data.subCategoryID = json['SubCategoryID'] is String
				? int.tryParse(json['SubCategoryID'])
				: json['SubCategoryID'].toInt();
	}
	if (json['ProductTypeID'] != null) {
		data.productTypeID = json['ProductTypeID'] is String
				? int.tryParse(json['ProductTypeID'])
				: json['ProductTypeID'].toInt();
	}
	if (json['BrandID'] != null) {
		data.brandID = json['BrandID'] is String
				? int.tryParse(json['BrandID'])
				: json['BrandID'].toInt();
	}
	if (json['ProdModelID'] != null) {
		data.prodModelID = json['ProdModelID'] is String
				? int.tryParse(json['ProdModelID'])
				: json['ProdModelID'].toInt();
	}
	if (json['FactoryBarCode'] != null) {
		data.factoryBarCode = json['FactoryBarCode'].toString();
	}
	if (json['BuyingProductsTime'] != null) {
		data.buyingProductsTime = json['BuyingProductsTime'];
	}
	if (json['ExpressNo'] != null) {
		data.expressNo = json['ExpressNo'].toString();
	}
	return data;
}

Map<String, dynamic> orderDetailOrderProductModelToJson(OrderDetailOrderProductModel entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['CategoryName'] = entity.categoryName;
	data['SubCategoryName'] = entity.subCategoryName;
	data['ProductType'] = entity.productType;
	data['ProdModelName'] = entity.prodModelName;
	data['BrandName'] = entity.brandName;
	data['Memo'] = entity.memo;
	data['Num'] = entity.num;
	data['OrderProdcutID'] = entity.orderProdcutID;
	data['SubCategoryID'] = entity.subCategoryID;
	data['ProductTypeID'] = entity.productTypeID;
	data['BrandID'] = entity.brandID;
	data['ProdModelID'] = entity.prodModelID;
	data['FactoryBarCode'] = entity.factoryBarCode;
	data['BuyingProductsTime'] = entity.buyingProductsTime;
	data['ExpressNo'] = entity.expressNo;
	return data;
}

orderDetailMasterInfoFromJson(OrderDetailMasterInfo data, Map<String, dynamic> json) {
	if (json['TrueName'] != null) {
		data.trueName = json['TrueName'].toString();
	}
	if (json['Avator'] != null) {
		data.avator = json['Avator'].toString();
	}
	if (json['TopRank'] != null) {
		data.topRank = json['TopRank'].toString();
	}
	if (json['UserID'] != null) {
		data.userID = json['UserID'].toString();
	}
	return data;
}

Map<String, dynamic> orderDetailMasterInfoToJson(OrderDetailMasterInfo entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['TrueName'] = entity.trueName;
	data['Avator'] = entity.avator;
	data['TopRank'] = entity.topRank;
	data['UserID'] = entity.userID;
	return data;
}